﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DA;

namespace ERP.Membership
{
    public class UserData
    {
        public int UserId { get; set; }
        public string Email { get; set; }
        public Permission Permissions { get; set; }
        public Guid UserGuid { get; set; }
        public IEnumerable<int> Roles { get; set; }

        public bool IsUserAllowed(IEnumerable<Permission> requieredPermissions)
        {
            return IsUserAllowed(requieredPermissions.ToArray());
        }

        public bool IsUserAllowed(params Permission[] requieredPermissions)
        {
            return !requieredPermissions.Any() || requieredPermissions.All(x => Permissions.HasFlag(x));
        }
    }
}
